#include "log.hh"
#include "gl/context.hh"
#include "gl/game.hh"
#include "fps_counter.hh"

int main()
{
	library::log() << "main(): enter\n";

	gl::context ctx{16*60, 9*60, "pilot3d"};
	gl::game game;

	library::log() << "main(): mainloop\n";
	auto last_time = ctx.tick();
	int step = 1000 / 120;
	int fps = 60;
	while (ctx) {
		fps_counter fc{fps, ctx};

		ctx.clear({0.1, 0.0, 0.1, 1});
		ctx.ui(false);
		game(ctx, false);
		ctx.ui(true);
		game(ctx, true);
		ctx.update();

		for (; ctx.tick() > last_time + step; last_time += step)
			game.update(step/1000.0, ctx, fps);

		if (ctx.key('\e')) break;
	}

	library::log() << "main(): leave\n";
}

